package Array;

import org.junit.Test;

/**
 * @BelongsProject: SeniorArchitect-LeetCode
 * @BelongsPackage: Array
 * @Author: zhuangxiaoyan
 * @CreateTime: 2023-10-18  11:08
 * @Description: TODO
 * @Version: 1.0
 */
public class 合并两个有序数组88 {

    public void merge(int[] nums1, int m, int[] nums2, int n) {
        int index=m+n-1;
        int first=m-1;
        int second=n-1;
        while (first>=0&&second>=0){
           if (nums1[first]>=nums2[second]){
               nums1[index--]=nums1[first--];
           }else {
               nums1[index--]=nums2[second--];
           }
        }
        while (first>=0){
            nums1[index--]=nums1[first--];
        }
        while (second>=0){
            nums1[index--]=nums2[second--];
        }
    }

    @Test
    public void test(){
        merge(new int[]{1},1,new int[]{},0);
    }
}
